package com.zzf.concurrent.example.design.pattern.balking;

import com.zzf.concurrent.example.util.TimeUtil;
import lombok.extern.slf4j.Slf4j;

/**
 * @author GaoFeng2017
 * @date 2019/9/8 19:26
 */
@Slf4j
public class SaverThread extends Thread {

    private Data data;

    public SaverThread(Data data) {
        this.data = data;
    }

    @Override
    public void run() {
        while (true) {
            boolean isSave = data.save();
            log.info("data is auto saved, {}.", isSave);
            TimeUtil.sleep(1000);
        }
    }

}
